/*******************************************OVERVIEW*******************************************************
 
Suffrage Reform and Financial Volatility
 
Replication file
 
Figure 2: Consol Excess Risk (1826-1835)
 
Version March 14 2022 
 
  
********************************************************************************************************************/

clear
set more off
#delimit ;


/*Set Directory -- You will need to adjust this line of code accordingly */; 


cd "/Users/ssaiegh/Files/Mac/JHPE";

/*Create Log File*/;

log using "Figure 2", replace text;


/*Load Data File*/;

use "cs_jhpe.dta";


/* Generate Data for Backtesting */; 


gen ret_ra=log(ra/L.ra);

drop product_gold;
drop product_rentes;
drop product_dutch;

gen double product_gold= gold/gold[1];
gen double product_rentes= french/french[1];
gen double product_dutch= dutch/dutch[1];
gen double product_ra= ra/ra[1];
gen double product_pound= ounces_pound/ounces_pound[1];


/*Estimate Returns of Regime Portfolio */; 


matrix GOV=(0.2\0.2\0.2\0.4);

matrix rownames GOV= CASH CONSOL RA INDIA;

cbacktest product_pound product_consol product_ra  bank_india, gen(govport) timevar(datevar) weights(GOV) nograph;

gen govport_1= govport+1;

gen ret_govport=log(govport_1/L.govport_1);


/*Estimate BETA coefficient */; 

regress ret_cons ret_govport;

regress ret_cons ret_govport if datevar>tm(1830m6) & datevar<tm(1832m4);

/*Estimate BETA coefficient (Rolling Regressions) */; 


rolling _b _se, window(12) stepsize(3) saving(betas, replace) keep(date): regress  ret_cons ret_govport;


/*Produce Figure 2 */; 

clear; 

use betas; 

generate lower = _b_ret_govport -1.96*_se_ret_govport;

generate upper = _b_ret_govport +1.96*_se_ret_govport;

twoway (line _b_ret_govport start, yline(1)) (rline lower upper start), ytitle("Beta");


log c;
 
